﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Besture.Bll;
using Besture.Common;
using Besture.Common.Helper;
using Besture.UI.Common;

namespace Besture.UI.Portal.UserCenter
{
    public partial class Comment : UserPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (StringHelper.Query("delId") != "")
                {
                    GetDelOrder(StringHelper.Query("delId").TrimEnd(','));
                } 
                InLoadBind();
            }
        }

        private int GetDelOrder(string sId)
        {
            return new AppraisalDac().DeleteList(sId);
        }

        private void InLoadBind()
        {
            var vAppraisalDt = new AppraisalDac().GetDataTableByUserId(LoginUserInfo.ID);
            if (vAppraisalDt.Rows.Count > 0)
            {

                AspNetPager1.RecordCount = vAppraisalDt.Rows.Count;
                PagedDataSource pds1 = new PagedDataSource
                {
                    AllowPaging = true,
                    DataSource = vAppraisalDt.DefaultView,
                    PageSize = AspNetPager1.PageSize,
                    CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1
                };
                rpAppraisal.DataSource = pds1;
                rpAppraisal.DataBind();
            }
        }

        /// <summary>
        /// 翻页
        /// </summary>
        /// <param name="src"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            InLoadBind();
            AspNetPager1.CurrentPageIndex = e.NewPageIndex;

        }

        public string GetReviewsReplyByReviewsId(int iReviewsId)
        { 
            var model = new ReviewsReplyDac().GetReviewsReplyByReviewsId(iReviewsId, GetUserLoginModel().ID);
            if (model!=null)
            {
                return model.ReplyContent;
            }
            return "";
        }
    }
}